$(document).ready(function() {
	var id = getQueryString('id');
	console.log(id);
	$.ajax({
		type : "post",
		url : "discussListOfArticle",
		async : true,
		data : {
			"id" : id
		},
		dataType : 'json',
		success : function(data) {
			var discusses = data.articleVo.discusses;
			var articlePath = 'myAssets//img//article//';// 文章文件路径
			var facePath = 'myAssets//img//face//';// 头像文件路径
			for (var i = 0; i < discusses.length; i++) {
				var userid = discusses[i].thisUser.id;
				var userName = discusses[i].thisUser.name;
				var discussesid = discusses[i].id;
				var dateProbably = getDateDiff(discusses[i].date.replace("T", " "));
				var content = discusses[i].content;
				var usetFile = facePath
						+ discusses[i].thisUser.myFile.name;
				var goodLength = discusses[i].goodDiscuss.length;
				var goalDiscussHashSetlength = discusses[i].goalDiscussHashSet.length;
				if (goodLength == 0) {
					goodLength = '';
				}
				if (goalDiscussHashSetlength == 0) {
					goalDiscussHashSetlength = '';
				}
		
				$("#discusses-list").append('	<div class="pet_comment_list_block"><a href="heUser?id='
						+ userid
						+ '"><div class="pet_comment_list_block_l"><img src="'
						+ usetFile
						+ '" alt=""></div>	<a /><div class="pet_comment_list_block_r"><a href="heUser?id='
						+ userid
						+ '"><div class="pet_comment_list_block_r_info">'
						+ userName
						+ '</div>	<a /><div class="pet_comment_list_block_r_text">'
						+ content
						+ '</div><div class="pet_comment_list_block_r_bottom">	<div class="pet_comment_list_bottom_info_l"style="color: #888888;">'
						+ dateProbably
						+ '</div>	<div class="pet_comment_list_bottom_info_r"><a href="###"> <span><i class="iconfont"><img src="myAssets/img/16-16/赞.png"></i>'
						+ goodLength
						+ '	</span>	</a> <a href="goalDiscussHashList?id='
						+ discussesid
						+ '"><span>'
						+ goalDiscussHashSetlength
						+ ' 回复</span></a>	</div>	</div>	</div>	</div>');
			}
			console.log(data)

		},
		error : function() {
		}
	});

})
// 获取url中的参数  
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); // 匹配目标参数
	var result = window.location.search.substr(1).match(reg); // 对querystring匹配目标参数
	if (result != null) {
		return decodeURIComponent(result[2]);
	} else {
		return null; 
	}
}

//发布时间'2017-03-26 09:29:34' 返回"几天前"
function getDateDiff(dateTimeStamp) {
	dateTimeStamp = Date.parse(dateTimeStamp.replace(/-/gi, "/"));
	var minute = 1000 * 60;
	var hour = minute * 60;
	var day = hour * 24;
	var halfamonth = day * 15;
	var month = day * 30;
	var now = new Date().getTime();
	var diffValue = now - dateTimeStamp;
	if (diffValue < 0) {
		return;
	}
	var monthC = diffValue / month;
	var weekC = diffValue / (7 * day);
	var dayC = diffValue / day;
	var hourC = diffValue / hour;
	var minC = diffValue / minute;
	if (monthC >= 1) {
		result = "" + parseInt(monthC) + "月前";
	} else if (weekC >= 1) {
		result = "" + parseInt(weekC) + "周前";
	} else if (dayC >= 1) {
		result = "" + parseInt(dayC) + "天前";
	} else if (hourC >= 1) {
		result = "" + parseInt(hourC) + "小时前";
	} else if (minC >= 1) {
		result = "" + parseInt(minC) + "分钟前";
	} else
		result = "刚刚";
	return result;
}